home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / 68kdis.zip / UNC.H < prev   
C/C++ Source or Header  |  1988-12-03  |  5KB  |  181 lines

  1. /*
  2.  *    SCCS:    @(#)unc.h    1.2    11/2/84    14:21:02
  3.  *    Header file for uncompile program.
  4.  *
  5.  ***********************************************************************
  6.  *    This software is copyright of
  7.  *
  8.  *        John M Collins
  9.  *        47 Cedarwood Drive
  10.  *        St Albans
  11.  *        Herts, AL4 0DN
  12.  *        England            +44 727 57267
  13.  *
  14.  *    and is released into the public domain on the following conditions:
  15.  *
  16.  *        1.  No free maintenance will be guaranteed.
  17.  *        2.  Nothing may be based on this software without
  18.  *            acknowledgement, including incorporation of this
  19.  *            notice.
  20.  *
  21.  *    Notwithstanding the above, the author welcomes correspondence and bug
  22.  *    fixes.
  23.  ***********************************************************************
  24.  */
  25.  
  26. #define    MAXCHARS    50
  27. #define    HASHMOD        97
  28.  
  29. /*
  30.  *    The following structure is used to keep track of symbols.
  31.  */
  32.  
  33. struct    symstr    {
  34.     struct    symstr    *s_next;        /*  Next in hash chain  */
  35.     struct    symstr    *s_link;        /*  Next in duplicate labels */
  36.     unsigned    s_type    :  5;        /*  Symbol type  */
  37.     unsigned    s_newsym:  1;        /*  A new symbol  */
  38.     unsigned    s_invent:  1;        /*  Invented symbol  */
  39.     unsigned    s_glob    :  1;        /*  Global symbol  */
  40.     long        s_value;        /*  Value if defined  */
  41.     short        s_defs;            /*  Defined count  */
  42.     short        s_used;            /*  Used count  */
  43.     unsigned short    s_lsymb;        /*  Local symbol  */
  44.     char        s_name[1];        /*  Chars of name null term */
  45. };
  46.  
  47. typedef    struct    symstr    *symbol;
  48.  
  49. symbol    symbhash[HASHMOD];
  50.  
  51. typedef    struct    {
  52.     int    ef_t;            /*  Text file fd  */
  53.     int    ef_d;            /*  Data file fd  */
  54.     long    ef_entry;        /*  Entry point  */
  55.     long    ef_tsize;        /*  Text size  */
  56.     long    ef_dsize;        /*  Data size  */
  57.     long    ef_bsize;        /*  Bss size  */
  58.     long    ef_end;            /*  End of it all  */
  59.     long    ef_tbase;        /*  Text base  */
  60.     long    ef_dbase;        /*  Data base  */
  61.     long    ef_bbase;        /*  Bss base  */
  62.     int    ef_stcnt;        /*  Number of symbols  */
  63.     int    ef_stmax;        /*  Max number of symbols  */
  64.     symbol    *ef_stvec;        /*  Symbol vector  */
  65. }  ef_fids;
  66.  
  67. typedef    ef_fids    *ef_fid;
  68.  
  69. /*
  70.  *    Description of word in text file.  This entry is held in the place
  71.  *    corresponding to the address in the text file.
  72.  */
  73.  
  74. typedef    struct    {
  75.     unsigned  short    t_contents;        /*  Actual contents  */
  76.     unsigned  short t_iindex;        /*  Index in table  */
  77.     unsigned    t_type    :  2;        /*  Type  */
  78.     unsigned    t_vins  :  1;        /*  Valid instruction  */
  79.     unsigned    t_bdest    :  1;        /*  Is branch dest  */
  80.     unsigned    t_gbdest:  1;        /*  Is global dest  */
  81.     unsigned    t_dref    :  1;        /*  Refered to in data  */
  82.     unsigned    t_bchtyp:  2;        /*  Branch type  */
  83.     unsigned    t_zilch    :  3;        /*  used to be t_lng */
  84.     unsigned    t_reloc :  2;        /*  Relocatable  */
  85.     unsigned    t_rptr    :  2;        /*  Where relocated  */
  86.     unsigned    t_rdisp :  1;        /*  Relocatable displacement */
  87.     unsigned    t_isrel :  1;        /*  Relocated  */
  88.     unsigned    t_amap    :  1;        /*  Worked out  */
  89.     short        t_lng;            /*  Length in words */
  90.     symbol        t_relsymb;        /*  Relocation symbol  */
  91.     long        t_reldisp;        /*  Offset + or - from symb */
  92.     symbol        t_lab;            /*  Label  */
  93.     unsigned  short    t_lsymb;        /*  Local symbol  */
  94.     long        t_reflo;        /*  Lowest place referred  */
  95.     long        t_refhi;        /*  Highest place referred  */
  96.     unsigned  short    t_match;        /*  Lib match lng  */
  97. }  t_entry;
  98.  
  99. /*
  100.  *    Types ......
  101.  */
  102.  
  103. #define    T_UNKNOWN    0
  104. #define    T_BEGIN        1
  105. #define    T_CONT        2
  106.  
  107. #define    R_NONE        0        /*  No relocation  */
  108. #define    R_BYTE        1        /*  Byte relocation  */
  109. #define    R_WORD        2        /*  Word relocation  */
  110. #define    R_LONG        3        /*  Long relocation  */
  111.  
  112. /*
  113.  *    Branch types.
  114.  */
  115.  
  116. #define    T_NOBR        0
  117. #define    T_CONDBR    1
  118. #define    T_UNBR        2
  119. #define    T_JSR        3
  120.  
  121. typedef    struct    {
  122.     unsigned  char    d_contents;        /*  Actual contents  */
  123.     unsigned    d_type  :  4;        /*  Data type  */
  124.     unsigned    d_reloc :  2;        /*  Relocatable  */
  125.     unsigned    d_rptr    :  2;        /*  Where relocated  */
  126.     short        d_lng;            /*  Length -ve for D_CONT */
  127.     symbol        d_relsymb;        /*  Relocation symbol  */
  128.     long        d_reldisp;        /*  Offset + or - from symb */
  129.     symbol        d_lab;            /*  Label  */
  130. }  d_entry;
  131.  
  132. /*
  133.  *    Data types.
  134.  */
  135.  
  136. #define    D_ASC        0        /*  Ascii chars  */
  137. #define    D_ASCZ        1        /*  Null-term ascii  */
  138. #define    D_BYTE        2        /*  Decimal bytes  */
  139. #define    D_WORD        3        /*  Words  */
  140. #define    D_LONG        4        /*  Longs  */
  141. #define    D_ADDR        5        /*  Address pointer  */
  142. #define    D_CONT        6        /*  Continuation of last  */
  143.  
  144. /*
  145.  *    'Common' items.
  146.  */
  147.  
  148. struct    commit    {
  149.     symbol    *c_symb;        /*  List of symbols  */
  150.     int    c_int;            /*  Current number  */
  151.     int    c_max;            /*  Maximum  */
  152. };
  153.  
  154. /*
  155.  *    Library file description.
  156.  */
  157.  
  158. struct    libit    {
  159.     LDFILE *ldptr,*ldptr2;        /*  independent file pointer packages
  160.                         for the same file */
  161.     char    lf_name[14];        /*  Name of item  */
  162. };
  163.  
  164. /* magic number stuff like Sun */
  165. #define OMAGIC 0407
  166. #define NMAGIC 0410
  167. #define ZMAGIC 0413
  168. #define N_BADMAG(x) \
  169.     (((x).magic)!=OMAGIC && ((x).magic)!=NMAGIC && ((x).magic)!=ZMAGIC)
  170.  
  171. /* definitions of type for Sun -- used for symstr.type, d_entry.d_rptr */
  172. #define S_UNDF 0x0        /* undefined */
  173. #define S_ABS  0x2        /* absolute */
  174. #define S_TEXT 0x4        /* text */
  175. #define S_DATA 0x6        /* data */
  176. #define S_BSS  0x8        /* bss */
  177. #define S_COMM 0x12        /* common (internal to ld) */
  178. #define S_FN   0x1f        /* file name symbol */
  179. #define S_EXT  01        /* external bit, or'ed in */
  180. #define S_TYPE 0x1e        /* mask for all the type bits */
  181.